﻿using Autofac;
using Autofac.Builder;

namespace GBlog.Core
{
    public static class ContainerBuilderExtensions
    {
        public static IRegistrationBuilder<T, ConcreteReflectionActivatorData, SingleRegistrationStyle> RegisterType<T, K>(this ContainerBuilder container, bool Override = false)
        {
            var output = container.RegisterType<T>().As<K>();
            if (!Override)
            {
                output.PreserveExistingDefaults();
            }
            return output;
        }
    }
}